Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Replace assert False with pytest.fail() #7546

Merged
merged 1 commit into from
Nov 12, 2023

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Nov 12, 2023

pytest.fail() gives slightly nicer errors:

https://docs.pytest.org/en/7.1.x/reference/reference.html#pytest-fail

import pytest


def test_a():
    assert False


def test_b():
    assert False, "abc"


def test_c():
    pytest.fail()


def test_d():
    pytest.fail("abc")
============================================================================================= FAILURES =============================================================================================
______________________________________________________________________________________________ test_a ______________________________________________________________________________________________

    def test_a():
>       assert False
E       assert False

1.py:5: AssertionError
______________________________________________________________________________________________ test_b ______________________________________________________________________________________________

    def test_b():
>       assert False, "abc"
E       AssertionError: abc
E       assert False

1.py:9: AssertionError
______________________________________________________________________________________________ test_c ______________________________________________________________________________________________

    def test_c():
>       pytest.fail()
E       Failed

1.py:13: Failed
______________________________________________________________________________________________ test_d ______________________________________________________________________________________________

    def test_d():
>       pytest.fail("abc")
E       Failed: abc

1.py:17: Failed
===================================================================================== short test summary info ======================================================================================
FAILED 1.py::test_a - assert False
FAILED 1.py::test_b - AssertionError: abc
FAILED 1.py::test_c - Failed
FAILED 1.py::test_d - Failed: abc
======================================================================================== 4 failed in 0.06s =========================================================================================

@hugovk hugovk added the Testing label Nov 12, 2023
@radarhere radarhere merged commit 25cc5af into python-pillow:main Nov 12, 2023
54 of 55 checks passed
@hugovk hugovk deleted the pytest-fail branch November 12, 2023 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants